package org.example.design.observer.test1;

/**
 * @author huangshen
 * @version 0
 * @description 以简单图示显示数值的类
 * @since 2022/2/11 13:59
 */
public class GraphObserver implements Observer {

    /**
     * 数值变化监控
     * @param numberGenerator 生成数值的对象的抽象类
     */
    @Override
    public void update(BaseNumberGenerator numberGenerator) {
        System.out.print("GraphObserver:");
        int count = numberGenerator.getNumber();
        for (int i = 0; i < count; i++) {
            System.out.print("*");
        }
        System.out.println();
        try {
            Thread.sleep(100);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
